﻿<Window x:Class="FolderBrowser.FolderBrowserDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        mc:Ignorable="d"
        x:Name="view"
        xmlns:system="clr-namespace:System;assembly=mscorlib"
        DataContext="{Binding ElementName=view, Path=ViewModel}"
        Width="400"
        Height="400"
        WindowStyle="ToolWindow"
        ResizeMode="CanResizeWithGrip"
        Title="Browse For Folder"
        Background="#FFD3CCCC">
   
    <DockPanel  Width="Auto"
                Height="Auto">


        <!-- The selected folder path -->
        <StackPanel DockPanel.Dock="Bottom">
            <TextBox Text="{Binding SelectedFolder}"
                     MinHeight="25"
                     Margin="5"
                     VerticalContentAlignment="Center" />
            <StackPanel Orientation="Horizontal"
                        HorizontalAlignment="Right">
                <Button Width="75"
                        Margin="10" Click="Ok_Click">Ok</Button>
                <Button Width="75"
                        Margin="10"
                        IsCancel="True">Cancel</Button>
            </StackPanel>
        </StackPanel>

        <DockPanel>

            <!-- Quick navigation panel on left-->
            <Border BorderThickness="2"
                    BorderBrush="Gray">
                <StackPanel Orientation="Vertical"
                            HorizontalAlignment="Left"
                            DockPanel.Dock="Left"
                            Background="#FF606060">
                    <Button Command="{Binding FolderSelectedCommand}"
                            CommandParameter="{x:Static system:Environment+SpecialFolder.Desktop }">
                        <StackPanel>
                            <Image Source="Images\Desktop.png"
                                   Height="35"
                                   Width="55" />
                            <TextBlock HorizontalAlignment="Center">Desktop</TextBlock>
                        </StackPanel>
                    </Button>

                    <Button Command="{Binding FolderSelectedCommand}"
                            CommandParameter="{x:Static system:Environment+SpecialFolder.ProgramFiles }">
                        <StackPanel>
                            <Image Source="Images\ProgramFiles.png"
                                   Height="35"
                                   Width="55" />
                            <TextBlock HorizontalAlignment="Center">Program Files</TextBlock>
                        </StackPanel>
                    </Button>

                    <Button Command="{Binding FolderSelectedCommand}"
                           CommandParameter="{x:Static system:Environment+SpecialFolder.MyDocuments }">
                     
                        <StackPanel>
                            <Image Source="Images\MyDocuments.png"
                                   Height="35"
                                   Width="55" />
                            <TextBlock HorizontalAlignment="Center">My Documents</TextBlock>
                        </StackPanel>
                    </Button>

                    <Button Command="{Binding FolderSelectedCommand}"
                            CommandParameter="{x:Static system:Environment+SpecialFolder.MyPictures }">
                        <StackPanel>
                            <Image Source="Images\MyPictures.png"
                                   Height="35"
                                   Width="55" />
                            <TextBlock HorizontalAlignment="Center">My Pictures</TextBlock>
                        </StackPanel>
                    </Button>

                </StackPanel>
            </Border>
            
            <!-- The windows explorer style treeview of folders -->
            <TreeView ItemsSource="{Binding Folders}"
                      SelectedValuePath="">
                <TreeView.ItemContainerStyle>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="IsExpanded"
                                Value="{Binding IsExpanded, Mode=TwoWay}" />
                        <Setter Property="IsSelected"
                                Value="{Binding IsSelected, Mode=TwoWay}" />
                        <Setter Property="FontWeight"
                                Value="Normal" />
                        <Style.Triggers>
                            <Trigger Property="IsSelected"
                                     Value="True">
                                <Setter Property="FontWeight"
                                        Value="Bold" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TreeView.ItemContainerStyle>

                <TreeView.ItemTemplate>
                    <HierarchicalDataTemplate ItemsSource="{Binding Folders}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding FolderIcon}"
                                   Margin="2"
                                   Height="13" />
                            <TextBlock Text="{Binding FolderName}"
                                       Margin="2"
                                       Height="13" />
                        </StackPanel>
                    </HierarchicalDataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>

        </DockPanel>

    </DockPanel>
</Window>